using System;
using System.Drawing.Drawing2D;
using System.Data;
using System.Data.Odbc;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class V2Controls_Top10ameldelser : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Table Tbl = new Table();
        TableRow TrTop = new TableRow();
        TableCell TdTop = new TableCell();
        Tbl.CellPadding = 0;
        Tbl.CellSpacing = 0;
        Tbl.BorderColor = System.Drawing.Color.Black;
        Tbl.BorderWidth = 1;
        Tbl.BorderStyle = BorderStyle.Solid;
        TdTop.CssClass = "TD_red";
        TdTop.Text = "&nbsp;Seneste Screenshots";
        TrTop.Cells.Add(TdTop);
        Tbl.Rows.Add(TrTop);

        OdbcDataReader MyReader = ReviewerOdbc.Read("SELECT V2_Screenshots.*, V2_Spil.Titel, V2_GloFormat.Navn FROM V2_Screenshots JOIN V2_Spil ON V2_Spil.SpilID = V2_Screenshots.SpilID JOIN V2_GloFormat ON V2_Screenshots.Format = V2_GloFormat.id GROUP BY V2_Spil.Titel ORDER BY V2_Screenshots.id DESC LIMIT 10");
        string Titel;
        while (MyReader.Read())
        {
            DateFromMySql DateHandler = new DateFromMySql();
            Titel = MyReader[4].ToString();
            
            if (Titel.Length > 30)
            {
                Titel = Titel.Substring(0, 30) + "...";
            }
            TableRow Tr2 = new TableRow();
            TableCell Td2 = new TableCell();
            Td2.Text = String.Format(
                "<a href=\"Screenshot.aspx?PicID={0}&SpilID={1}\" style=\"color:black;\">{2}<br /><img style=\"border:1px solid black;\" height=\"40px\" src=\"screenshots/{3}\" /></a>"
                , MyReader[0].ToString() //Link
                , MyReader[1].ToString() //SpilId
                , Titel //Link Text
                , MyReader["Filnavn"].ToString()); //Filename Text
            //Td2.Text = "<a href=\"Screenshot.aspx?PicID=" + MyReader[0].ToString() + "&SpilID=" + MyReader[1].ToString() + "\" style=\"color:black;\">" + Titel + "<br /><img style=\"border:1px solid black;\" height=\"40px\" src=\"screenshots/" + MyReader["Filnavn"].ToString() + "\">";
            Td2.CssClass = "TD_Top10Screens";
            Td2.VerticalAlign = VerticalAlign.Top;
            Tr2.Cells.Add(Td2);
            Tbl.Rows.Add(Tr2);
        }

        Top10Holder.Controls.Add(Tbl);
    }
}
